package com.atlzk.group.tgou.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.atlzk.group.tgou.entity.MiaoShopEntity;
import com.atlzk.group.tgou.service.MiaoShopService;
import com.atlzk.common.utils.PageUtils;
import com.atlzk.common.utils.R;


/**
 * @author liuzekun
 * @email 2803587841@gmail.com
 * @date 2021-06-29 09:58:59
 */
@RestController
@RequestMapping("tgou/miaoshop")
//@CrossOrigin
public class MiaoShopController {
    @Autowired
    private MiaoShopService miaoShopService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("tgou:miaoshop:list")
    public R list(@RequestParam Map <String, Object> params) {
        PageUtils page = miaoShopService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{smsMshopId}")
    //@RequiresPermissions("tgou:miaoshop:info")
    public R info(@PathVariable("smsMshopId") Long smsMshopId) {
        MiaoShopEntity miaoShop = miaoShopService.getById(smsMshopId);

        return R.ok().put("miaoShop", miaoShop);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("tgou:miaoshop:save")
    public R save(@RequestBody MiaoShopEntity miaoShop) {
        miaoShopService.save(miaoShop);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("tgou:miaoshop:update")
    public R update(@RequestBody MiaoShopEntity miaoShop) {
        miaoShopService.updateById(miaoShop);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("tgou:miaoshop:delete")
    public R delete(@RequestBody Long[] smsMshopIds) {
        miaoShopService.removeByIds(Arrays.asList(smsMshopIds));

        return R.ok();
    }

    /**
     * 信息
     */
    @RequestMapping("miaoShopbyId/{smsMshopId}")
    //@RequiresPermissions("tgou:miaoshop:info")
    public MiaoShopEntity MiaoShopbyId(@PathVariable("smsMshopId") Long smsMshopId) {
        MiaoShopEntity miaoShop = miaoShopService.getById(smsMshopId);
        return miaoShop;
    }

    /**
     * 修改
     */
    @RequestMapping("/subtractRepertory")
    //@RequiresPermissions("tgou:miaoshop:update")
    public R subtractRepertory(@RequestBody MiaoShopEntity miaoShop) {
        miaoShopService.subtractRepertory(miaoShop);
        return R.ok();
    }

    @GetMapping("/miaoShoplist")
    public List <MiaoShopEntity> miaoShoplist() {
        return miaoShopService.list();
    }
}
